<template>
 <div class="background"> 
   <div class="login">
      <h3>若依后台管理系统</h3>
      
     <el-form :model="ruleForm" status-icon :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
  
  <el-form-item label="账号" prop="pass">
    <el-input type="username" v-model="ruleForm.pass" autocomplete="off"></el-input>
  </el-form-item>
  <el-form-item label="密码" prop="checkPass">
    <el-input type="password" v-model="ruleForm.checkPass" autocomplete="off"></el-input>
  </el-form-item>

   <el-form-item>
   <el-checkbox v-model="checked">记住密码</el-checkbox>
    </el-form-item>
 <router-link to='/admin'>
  <el-form-item>
    <el-button type="primary" style="width:100%"  >登录</el-button>
  </el-form-item>
  </router-link>
</el-form>
</div>
</div>
</template>

<script>
  export default {
    data() {
      var validatePass = (rule, value, callback) => {
        if (value === '') {
          callback(new Error('请输入账号'));
        } else {
          if (this.ruleForm.username !== '') {
            this.$refs.ruleForm.validateField('checkPass');
          }
          callback();
        }
      };
      var validatePass2 = (rule, value, callback) => {
        if (value === '') {
          callback(new Error('请输入密码'));
        } else if (value !== this.ruleForm.pass) {
          callback(new Error('密码不正确'));
          }else{
             callback();
          }
        };

      return {
        ruleForm: {
          pass: 'admin',
          checkPass: 'admin',
        },
      
        rules: {
          pass: [
            { validator: validatePass, trigger: 'blur' }
          ],
          checkPass: [
            { validator: validatePass2, trigger: 'blur' }
          ],
     
      }
       }  
      }
      } 
  
  
</script>

<style scoped>
.login{
   display: flex;
    flex-direction: column;
    align-items: center;
    margin-right: 120px ;
} 
h3{
  margin:160px 0px 20px 80px ;
}
.background {
  background: url("../login/w.jpg");
  background-position: center;
  height: 100%;
  width: 100%;
  background-size: cover;
  position: fixed;
}
</style>